package pers.course.week9;

import java.util.*;

public class Hashset {
    public static HashSet<String> union(HashSet<String> set1, HashSet<String> set2) {
        HashSet<String> set3 = new HashSet<String>(set1);
        set3.addAll(set2);
        return set3;
    }
    public static HashSet<String> difference(HashSet<String> set1, HashSet<String> set2) {
        HashSet<String> set3 = new HashSet<String>(set1);
        set3.removeAll(set2);
        return set3;
    }
    public static HashSet<String> intersection(HashSet<String> set1, HashSet<String> set2) {
        HashSet<String> set3 = new HashSet<String>(set1);
        set3.retainAll(set2);
        return set3;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.nextLine();
        String [] strings1 = new String[20];
        strings1 = s1.split(" ");
        HashSet<String> set1 = new HashSet<String>(Arrays.asList(strings1));
        String s2 = in.nextLine();
        String [] strings2 = new String[20];
        strings2 = s2.split(" ");
        HashSet<String> set2 = new HashSet<String>(Arrays.asList(strings2));
        StringBuilder sb1 = new StringBuilder();
        for (String str : union(set1, set2)) {
            sb1.append(str.trim()).append(", ");
        }
        String str1 = sb1.toString();
        System.out.println(str1.substring(0, (str1.length() - 2)));
        StringBuilder sb2 = new StringBuilder();
        for (String str : difference(set1, set2)) {
            sb2.append(str.trim()).append(", ");
        }
        String str2 = sb2.toString();
        System.out.println(str2.substring(0, (str2.length() - 2)));
        StringBuilder sb3 = new StringBuilder();
        for (String str : intersection(set1, set2)) {
            sb3.append(str.trim()).append(", ");
        }
        String str3 = sb3.toString();
        System.out.println(str3.substring(0, (str3.length() - 2)));
    }
}
